<script>
$(document).ready(function(){
	//Definimos que todos as tags dd terão display:none menos o primeiro filho
	$('dd').hide();
	//Ao clicar no link, executamos a funcão
	$('dt a').live('click',function(){
		id = $(this).attr("name")
		 url = '/admin/transaction-detail?transaction_id=' + id;
		    $.get(url, function(data){
		    $('#' + id + '').html(data);
		    });
		
		//As tags dd's visíveis agora ficam com display:none
		$("dd:visible").slideUp("fast");
		//Após, a funcão é transferida para seu pai, que procura o próximo irmão no código o tonando visível
		$(this).parent().next().slideDown("fast");
		return false;
	});
});
</script>

<a href="/admin/list-transactions?city=Araraquara">Vendas em Araraquara</a>

<a style="margin-left: 50px;" href="/admin/list-transactions">Vendas no Brasil</a>

<h2 class="partner-title" style="width: 100%;">Transações no Sistema</h2>
<div id="list-content">
<?php if($this->user['user_type'] == 1):?>
<div id="list-clients">
<div class="search-header">
	<input type="hidden" value="<?php echo $this->city;?>" name="city" id="city">
	<span>
		Status <select id="status" name="status" onchange="getPaginatedAdminTransactions('/admin/search-transaction', 'transaction')">
					<option value="" selected="selected">Todos</option>
					<?php foreach ($this->listStatus as $status):?>
						<option value="<?php echo $status['id_status']?>"><?php echo utf8_encode($status['description'])?></option>
					<?php endforeach;?>
				</select>
	</span>
	<span>
		Buscar: <input type="text" id="searchTra" name="searchTra" onkeyup="getPaginatedAdminTransactions('/admin/search-transaction', 'transaction')">
	</span>
	<span>
		Data de: <input type="text" class="datepicker" id="initial"/>
	</span>
	<span>
		até: <input type="text" class="datepicker" id="final"/>
	</span>
</div>

<div id="transaction">
<?php endif;?>

<?php if ($this->listTransactions != null):?>
<div style="height: 35px;">
	<h2 class="partner-title" style="width: 20%;">Transação</h2>
	<h2 class="partner-title" style="width: 20%;">Cliente</h2>
	<h2 class="partner-title" style="width: 20%;">Data</h2>
	<h2 class="partner-title" style="width: 20%;">Data de update</h2>
	<h2 class="partner-title" style="width: 20%;">Status</h2>
</div>

<dl style="width: 1024px;">
<?php foreach ($this->listTransactions as $request):?>
	<dt>
		<a title="<?php echo $request['id_transaction']?>" href="" class="transaction" style="width: 20%;"
			name="<?php echo $request['id_transaction']?>"> 
			<?php if(strlen($request['id_transaction']) > 17):?>
				<?php echo substr($request['id_transaction'], 0, 17).'...'?> 
			<?php else:?>
				<?php echo $request['id_transaction']?>
			<?php endif;?>
		</a> 
		<a href="" class="transaction" style="width: 20%;"
			name="<?php echo $request['id_transaction']?>"> 
			<?php if(strlen($request['name']) > 17):?>
				<?php echo substr($request['name'], 0, 17).'...'?> 
			<?php else:?>
				<?php echo $request['name']?>
			<?php endif;?>
		</a>
		<a href="" class="transaction" style="width: 20%;"
			name="<?php echo $request['id_transaction']?>"> <?php echo date("d/m/Y H:i", strtotime($request['date']));?>
		</a> 
		<a href="" class="transaction" style="width: 20%;"
			name="<?php echo $request['id_transaction']?>"> <?php echo date("d/m/Y H:i", strtotime($request['date_update']));?>
		</a> 
		<a href="" class="transaction" style="width: 20%;"
			name="<?php echo $request['id_transaction']?>"> 
			<?php echo utf8_encode($request['description'])?>
		</a>
	</dt>
	<dd>
		<ul>
			<li>
				<div id="<?php echo $request['id_transaction']?>"></div>
			</li>
		</ul>
	</dd>
	<?php endforeach;?>
	<!-- PAGINAÇÃO -->
		<?php echo $this->paginationControl($this->listTransactions, 'Sliding', '/admin/_pagination-transactions.phtml'); ?>
	<!-- [END] PAGINAÇÃO -->
</dl>
	<?php else:?>
<div class="nothing">
	<p>Nenhum pedido foi efetuado!</p>
</div>
<?php endif;?>
</div>
</div>
<p></p>

</div>